.TH std::moneypunct::pos_format,do_pos_format,neg_format,do_neg_format 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::moneypunct::pos_format,do_pos_format,neg_format,do_neg_format \- std::moneypunct::pos_format,do_pos_format,neg_format,do_neg_format

.SH Synopsis
   Defined in header <locale>
   public:                                \fB(1)\fP
   pattern pos_format() const;
   public:                                \fB(2)\fP
   pattern neg_format() const;
   protected:                             \fB(3)\fP
   virtual pattern do_pos_format() const;
   protected:                             \fB(4)\fP
   virtual pattern do_neg_format() const;

   1) Public member function, calls the member function do_pos_format of the most
   derived class.
   2) Public member function, calls the member function do_neg_format of the most
   derived class.
   3) Returns the format structure (of type std::money_base::format) which describes
   the formatting of positive monetary values.
   4) Returns the format structure (of type std::money_base::format) which describes
   the formatting of negative monetary values.

   The standard specializations of std::moneypunct return the pattern {symbol, sign,
   none, value}.

.SH Return value

   The object of type std::money_base::format describing the formatting used by this
   locale.

.SH Notes

   While std::money_put uses pos_format for formatting positive values and neg_format
   for formatting negative values, std::money_get uses neg_format for parsing all
   monetary values: it assumes that neg_format is compatible with pos_format.

.SH Example


// Run this code

 #include <iomanip>
 #include <iostream>
 #include <locale>

 struct my_punct : std::moneypunct_byname<char, false>
 {
     my_punct(const char* name) : moneypunct_byname(name) {}
     pattern do_pos_format() const { return {value, space, symbol, sign}; }
     pattern do_neg_format() const { return {value, space, symbol, sign}; }
 };

 int main()
 {
     std::cout.imbue(std::locale("en_US.utf8"));
     std::cout << "american locale: " << std::showbase
               << std::put_money(12345678.0) << '\\n';

     std::cout.imbue(std::locale(std::cout.getloc(), new my_punct("en_US.utf8")));
     std::cout << "locale with modified moneypunct:\\n"
               << std::put_money(12345678.0) << '\\n'
               << std::put_money(-12345678.0) << '\\n';
 }

.SH Output:

 american locale: $123,456.78
 locale with modified moneypunct:
 123,456.78 $
 123,456.78 $-

.SH See also

   do_curr_symbol   provides the string to use as the currency identifier
   \fB[virtual]\fP        \fI(virtual protected member function)\fP
   do_positive_sign provides the string to indicate a positive or negative value
   do_negative_sign \fI(virtual protected member function)\fP
   \fB[virtual]\fP
   do_get           parses a monetary value from an input stream
   \fB[virtual]\fP        \fI\fI(virtual protected member function\fP of\fP
                    std::money_get<CharT,InputIt>)
   do_put           formats a monetary value and writes to output stream
   \fB[virtual]\fP        \fI\fI(virtual protected member function\fP of\fP
                    std::money_put<CharT,OutputIt>)
